﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components {
    import flash.events.*;
    import flash.display.*;
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import __AS3__.vec.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;

    public class PlaceHolderView extends Sprite {

        private var m_roomPlaceholders:Vector.<PlaceHolder>;

        public function PlaceHolderView(){
            this.m_roomPlaceholders = new Vector.<PlaceHolder>();
            super();
        }
        public function showRoomSnapareas(_arg1:MovieClip, _arg2:Vector.<Slot>):void{
            var _local4:Slot;
            var _local5:Class;
            var _local6:MovieClip;
            var _local7:PlaceHolder;
            this.m_roomPlaceholders = new Vector.<PlaceHolder>();
            var _local3:int;
            while (_local3 < _arg2.length) {
                _local4 = _arg2[_local3];
                _local5 = (getDefinitionByName(getQualifiedClassName(_arg1)) as Class);
                _local6 = new (_local5);
                _local6.name = ShopItemVO.DESTINATION_ROOM;
                _local6.width = GameConstants.ROOM_WIDTH;
                _local6.height = GameConstants.ROOM_HEIGHT;
                _local7 = new PlaceHolder();
                _local7.addChild(_local6);
                _local7.addEventListener(MouseEvent.MOUSE_OVER, this.onSnapIn);
                _local7.addEventListener(MouseEvent.MOUSE_OUT, this.onSnapOut);
                _local7.x = _local4.position.x;
                _local7.y = _local4.position.y;
                _local7.slot = _local4;
                this.addChild(_local7);
                this.m_roomPlaceholders.push(_local7);
                _local3++;
            };
        }
        private function onSnapIn(_arg1:MouseEvent):void{
            var _local2:PlaceHolder = PlaceHolder(_arg1.currentTarget);
            var _local3:SnapEvent = new SnapEvent(EventConstants.SNAP_IN, _local2);
            _local3.slotId = _local2.slot.id;
            dispatchEvent(_local3);
        }
        private function onSnapOut(_arg1:MouseEvent):void{
            dispatchEvent(new Event(EventConstants.SNAP_OUT));
        }
        public function cleanup():void{
            var _local1:int;
            while (_local1 < this.m_roomPlaceholders.length) {
                this.m_roomPlaceholders[_local1].removeEventListener(MouseEvent.MOUSE_OVER, this.onSnapIn);
                this.m_roomPlaceholders[_local1].removeEventListener(MouseEvent.MOUSE_OUT, this.onSnapOut);
                removeChild(this.m_roomPlaceholders[_local1]);
                _local1++;
            };
            this.m_roomPlaceholders = new Vector.<PlaceHolder>();
        }

    }
}//package net.wooga.pets.views.components 
